﻿using System;
using System.Linq.Expressions;

namespace GSite.Utils.Expressions.ExpressionUtil
{
    internal static class ExpressionParser
    {
        public static ParserContext Parse<TModel, TValue>(Expression<Func<TModel, TValue>> expression)
        {
            ParserContext context = new ParserContext()
            {
                ModelParameter = expression.Parameters[0]
            };

            Expression body = expression.Body;
            context.Fingerprint = ExpressionFingerprint.Create(body, context);
            return context;
        }
    }
}
